<!--!
This file is a part of MediaDrop (https://www.mediadrop.video),
Copyright 2009-2018 MediaDrop contributors
For the exact contribution history, see the git revision log.
The source code contained in this file is licensed under the GPLv3 or
(at your option) any later version.
See LICENSE.txt in the main project directory, for more information.
-->
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      py:strip="">
	<form method="post" action="${h.url_for(action='update_status')}" id="update-status-form" class="box">
		<div class="box-head">
			<span class="box-head-sec">
				<!--!${h.doc_link('admin/media', 'status')}-->
				<py:if test="media.slug">
					<py:choose test="media.is_published">
						<py:when test="1">
							<a href="${h.url_for_media(media)}"
							   id="go-view-content"
							   title="View this media where it is published">${ngettext('View', 'Views', 1)}</a>
						</py:when>
						<py:when test="0">
							<a href="${h.url_for_media(media)}"
							   id="go-view-content"
							   title="View this media where it will be published"
							   py:content="_('Preview')" />
						  </py:when>
					</py:choose>
				</py:if>
			</span>
			<h1>Publish Status</h1>
		</div>
		<div class="box-content" py:choose="" 
		    py:with="publish_on=(media.publish_on and media.publish_on.strftime('%b %d %Y @ %H:%M')) or None;
		        publish_until = (media.publish_until and media.publish_until.strftime('%b %d %Y @ %H:%M')) or None;">
			<input py:replace="c.publish_on(publish_on)" />
			<input type="hidden" name="is_published" value="${int(media.is_published)}" />
			<input py:replace="c.publish_until(publish_until)" />
			<py:when test="media.id is None">
				<div class="center">You must add a file and save before review can begin.</div>
			</py:when>
			<py:when test="not media.reviewed">
				<ol class="status-list">
					<li class="status-list-inprogress">Review Pending</li>
					<li class="status-list-${media.encoded and 'complete' or 'pending'}">${media.encoded and _('Encoding Complete') or _('Encoding Pending')}</li>
					<li class="status-list-pending" id="status-publish" title="Click to change the publish date">
						Publishing <span class="publish-date" py:content="publish_on or _('Pending')" />
					</li>
				</ol>
				<div class="center" py:choose="">
					<py:when test="media.files">
						${c.status('unreviewed')}
						${c.update_button(_('Review Complete'), id='update-status', css_class='btn green btn-review-complete')}
					</py:when>
					<py:otherwise><div style="margin-top:10px">Review can only be completed after a file is added.</div></py:otherwise>
				</div>
			</py:when>
			<py:when test="not media.encoded">
				<ol class="status-list">
					<li class="status-list-complete">Review Complete</li>
					<li class="status-list-inprogress">Encoding Pending</li>
					<li class="status-list-pending" id="status-publish" title="Click to change the publish date">
						Publishing <span class="publish-date" py:content="publish_on or _('Pending')" />
					</li>
				</ol>
				<div class="center" style="margin-top:10px">Encoding will be complete when an acceptable file is added.</div>
			</py:when>
			<py:when test="not media.publishable">
				<ol class="status-list">
					<li class="status-list-complete">Review Complete</li>
					<li class="status-list-complete">Encoding Complete</li>
					<li class="status-list-inprogress" id="status-publish" title="Click to change the publish date">
						Publishing <span class="publish-date" py:content="publish_on or _('Pending')" />
					</li>
				</ol>
				<div class="center">
					${c.status('draft')}
					${c.update_button(_('Publish Now'), id='update-status', css_class='btn green btn-publish-now')}
				</div>
			</py:when>
			<py:when test="media.publishable">
				<ol class="status-list">
					<li class="status-list-complete">Review Complete</li>
					<li class="status-list-complete">Encoding Complete</li>
					<li class="status-list-complete" id="status-publish" title="Click to change the publish date">
						${media.is_published and _('Published') or _('Publishing')}
						<span class="publish-date" py:content="publish_on or _('Pending')" />
					</li>
				</ol>
			</py:when>
            <ol class="status-list media-expiry">
                <li class="status-list-expiry" id="status-expiry" title="Click to change the expiration date">
                    Expires <span class="expiry-date" py:content="publish_until or _('never')" />
                </li>
            </ol>
			<div py:if="defined('status_error') and status_error" py:content="status_error" class="center" />
		</div>
		<div id="update-status-error" class="box-error hidden" />
	</form>
</html>
